package org.example;

public class Tesst {


    public static void main(String[] args) {
        String sql = "insert into etl_dwd.dwd_patrol_event_rect\n" +
                "\tSELECT\n" +
                "\t\ta.create_year,\n" +
                "\t\ta.area_name,\n" +
                "\t\ta.project_name,\n" +
                "\t\tcount(\n" +
                "\t\t\tCASE\n" +
                "\t\t\t\tWHEN a.state in('0') THEN\n" +
                "\t\t\t\t\t1\n" +
                "\t\t\tEND\n" +
                "\t\t) as nodistribute,\n" +
                "\t\tcount(\n" +
                "\t\t\tCASE\n" +
                "\t\t\t\tWHEN a.state in('1') THEN\n" +
                "\t\t\t\t\t1\n" +
                "\t\t\tEND\n" +
                "\t\t) as aldistribute,\n" +
                "\t\tcount(\n" +
                "\t\t\tCASE\n" +
                "\t\t\t\tWHEN a.state in('2') THEN\n" +
                "\t\t\t\t\t1\n" +
                "\t\t\tEND\n" +
                "\t\t) as alrectdistribute\n" +
                "\tFROM\n" +
                "\t\t(select etl_dwd.dwd_patrol_event_detail.create_year,etl_dwd.dwd_patrol_event_detail.project_name,etl_dwd.dwd_cisdi_area_info.area_name,etl_dwd.dwd_patrol_event_detail.state from etl_dwd.dwd_patrol_event_detail left join etl_dwd.dwd_cisdi_event_middle_area on etl_dwd.dwd_patrol_event_detail.`event_id` = etl_dwd.dwd_cisdi_event_middle_area.`projectId`left join etl_dwd.dwd_cisdi_area_info on etl_dwd.dwd_cisdi_event_middle_area.`powerId` = etl_dwd.dwd_cisdi_area_info.`area_id`) a\n" +
                "\tGROUP BY\n" +
                "\t\ta.create_year,\n" +
                "\t\ta.area_name,\n" +
                "\t\ta.project_name";
        sql = sql.replaceAll("(?<!\\.)`", " ").replaceAll("\\.`", ".");
        System.out.println(sql);

    }
}
